<template>
  <div>
    <button @click="getRef">获取Header组件上的ref</button>
    <MyHeader />
    <br />
    <Mycount ref="HeaderComp" />
  </div>
</template>

<script>
import MyHeader from "./components/MyHeader";
import Mycount from "./components/MyCount";
export default {
  name: "App",
  components: {
    MyHeader,
    Mycount,
  },
  methods: {
    getRef() {
      //  如果把ref属性写在一个组件上,那么$refs对象上保存的是组件实例
      console.log(this.$refs.HeaderComp, "我是组件上的ref");
    },
  },
};
</script>

<style scoped>
</style>